<?php

	include "../controller/ConectBanco.php";

class DeviceDAO{

	function insert(Device $device){
	    									
		mysql_query("INSERT INTO device SET idApn = '".$device->getIdApn()."'
							, idModel = '". $device->getIdFeature()."'
							, idDriver = '". $device->getIdDriver()."'
							, idSimCard = '". $device->getIdSimCard()."'
							, imei = '". $device->getImei()."'
							, conect = 0")	or die (mysql_error());	
		
		header("location:../view/ListaDevices.php");
		
	}
	
	function delete($idDevice){
		mysql_query("DELETE FROM device WHERE idDevice =".$idDevice) or die (mysql_error());	
		
		header("location:../view/ListaDevices.php");
	}
	
	function update(Device $device){
		mysql_query("UPDATE device SET idApn='".$device->getIdApn()."'
									  ,idModel='".$device->getIdFeature()."' 
									  ,idDriver='".$device->getIdDriver()."'
									  ,idSimCard = '". $device->getIdSimCard()."'		 
									  ,imei='".$device->getImei()."' WHERE idDevice='".$device->getIdDevice()."'") or die (mysql_error());	
		
		header("location:../view/ListaDevices.php");
	}
}	
	
?>